/*
 * $Id: BreakingNews.java 94 2013-01-10 14:03:20Z vladimirow@mail.ru $
 * $HeadURL: http://ultralog.googlecode.com/svn/ultralog/trunk/src-example/java/BreakingNews.java $
 *
 * This file is a part of ultralog project (http://code.google.com/p/ultralog/).
 * Released under New BSD License.
 */

import com.google.code.ultralog.BasicLogger;
import com.google.code.ultralog.LogLevel;
import com.google.code.ultralog.LogLevelChecker;
import com.google.code.ultralog.LogMessage;
import com.google.code.ultralog.LoggerManager;

/**
 * Example that shows how to define new logging level.
 *
 * @author Mikhail Vladimirov
 */
public class BreakingNews
{
    /**
     * Entry point of the example.
     *
     * @param args command-line arguments
     */
    public static void main (String [] args)
    {
        BreakingNewsLogger logger =
            LoggerManager.createLogger (BreakingNewsLogger.class);

        if (logger.isBreakingNewsEnabled ())
            logger.elephant ("city hall");
    }

    /**
     * Logger interface that defines new logging level.
     */
    protected interface BreakingNewsLogger extends BasicLogger
    {
        /**
         * Breaking news logging level ({@value #BREAKING_NEWS}).  This logging
         * level is for breaking news messages.
         */
        @LogLevel
        int BREAKING_NEWS = 3500;

        /**
         * Tells whether breaking news logging level is enabled for this logger.
         *
         * @return <code>true</code> if breaking news logging level is enabled,
         *         <code>false</code> otherwise
         */
        @LogLevelChecker (level = BREAKING_NEWS)
        boolean isBreakingNewsEnabled ();

        /**
         * Log a message at breaking news logging level.
         *
         * @param where parameter to be substituted into the message.
         */
        @LogMessage (
            level = BREAKING_NEWS, template = "Elephant was seen near ${1}!")
        void elephant (String where);
    }
}
